package com.example.dell.newstart.my;

import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.dell.newstart.R;
import com.example.dell.newstart.base.BaseFragment;
import com.example.dell.newstart.bean.MyApp;
import com.example.dell.newstart.login.Login;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;

public class MyFragment extends BaseFragment implements View.OnClickListener {
    @BindView(R.id.my_user_name)
    TextView etUserName;
    @BindView(R.id.my_zhanghao)
    TextView etZhanghao1;
    Unbinder unbinder;
    @Override
    protected int initLayout() {

        return R.layout.fragment_my;
    }

    @Override
    protected void initView() {
        unbinder = ButterKnife.bind(this, getContentView());


        ImageView button = getContentView().findViewById(R.id.login_botton);
        ImageView imageView = getContentView().findViewById(R.id.my_information);
        ImageView imgSetupView=getContentView().findViewById(R.id.my_setup);
        button.setOnClickListener(this);
        imageView.setOnClickListener(this);
        imgSetupView.setOnClickListener(this);
    }




    @Override
    protected void initData() {


       if (MyApp.getCurrentUser()!=null) {
           etUserName.setText(MyApp.getCurrentUser().getUsername());
           etZhanghao1.setText((MyApp.getCurrentUser().getId()).toString());
           //toastShort("点击了512");
       }

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.login_botton:
                if(MyApp.getCurrentUser()==null) {
                    goNextActivity(Login.class);
                }else {
                    goNextActivity(MyInformationActivity.class);
                    //toastShort("点击了");
                }
                break;
            case R.id.my_information:
                goNextActivity(MyInformationActivity.class);
                break;
            case R.id.my_setup:
                goNextActivity(MySetUpActivity.class);
                break;
        }
    }
}
